Talking about static a [n*m] = {0}; The role of static in

  • 2021-12-09 09:48:38
  • OfStack

As we know, all the variables and arrays in the function open up memory in the stack area, but the memory in the stack area is limited. When the memory we want to open up is large, the compiler will report an error. What should we do?

We also know that static int a; It means that the variable a is allocated memory in the global area. Similarly, after we add static in front of the array, the system also allocates memory for the array in the global area. The total memory in the global area is relatively large, and 1 will generally meet our needs.

For example, when n*m is relatively large, this is why static a [n*m] = {0}; You must take the reason of static with you.


Related articles: